<template>
  <div id="app">
    <div class="sys-title">
      机票预订系统 By BUAA21-Team:KYR
    </div>
    <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect"
      text-color="black" active-text-color="black" font-size='20px'>
      <el-tooltip>
        <div slot="content">端午节快乐，买个机票吧<br />球球你了！！</div>
        <img src="./assets/sys-logo.png" height="61px">
      </el-tooltip>
      <!-- 未登录显示 -->
      <!-- 已登录显示 -->
      <!-- 管理员界面 -->
      <el-menu-item index="3" v-if="this.$GLOBAL.is_admin">
        <router-link to="/admin" class="please-admin">管理员</router-link>
      </el-menu-item>
      <template v-else>
        <el-menu-item index="0">
          <router-link to="/" class="please">首页</router-link>
        </el-menu-item>
        <template v-if="this.$GLOBAL.is_login == false">
          <el-menu-item index="1" v-if="this.$GLOBAL.is_login!=true">
            <router-link to="/login" class="please-login">登录</router-link>
          </el-menu-item>
          <el-menu-item index="2">
            <router-link to="/register" class="please-register">注册</router-link>
          </el-menu-item>
        </template>
        <!-- 用户登录 -->
        <el-menu-item index="4" v-else>
          <router-link to="/user" class="please-user">个人信息</router-link>
        </el-menu-item>
      </template>
      <el-menu-item index="5" v-if="this.$GLOBAL.is_login">
        <el-button plain round @click="userLogout">注 销</el-button>
      </el-menu-item>
    </el-menu>
    <transition name="slide" mode="out-in">
      <router-view />
    </transition>
  </div>
</template>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  background-color: rgb(233, 238, 243);
  height: 963px;
  /* 背 景 图 片 */
  /*background-image: url('../src/assets/blackpink.jpg');
  background-repeat: no-repeat;
  background-size: cover;*/
}
a {
  text-decoration: none;
  font-size: 18px;
}
#nav a {
  font-weight: bold;
  color: #999;
  text-decoration: none;
}

#nav a.router-link-exact-active {
  color: #42b983;
}
#nav a.router-link {
  text-decoration: none;
}
#app .el-menu-demo {
  background-color: rgb(253, 253, 253);
}
.sys-title {
  font-size: 30px;
  height: 50px;
  color: white;
  background: url("assets/title-background.jpg") no-repeat center center;
}
/* 动画效果 */
.slide-leave-active,
.slide-enter-active {
  transition: opacity 0.5s, transform 0.5s;
}
.slide-enter,
.slide-leave-to {
  opacity: 0;
  transform: translateX(-30%);
}
</style>

<script>
export default {
  data() {
    return {
      activeIndex: "0"
    };
  },
  methods: {
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
    },
    userLogout() {
      this.activeIndex = "0";
      this.$GLOBAL.is_login = false;
      this.$GLOBAL.is_admin = false;
      this.$router.go(0)
    }
  },
  computed: {}
};
</script>